#!/usr/bin/env bash
# 将执行目录移动到 当前文件所在目录
cd `dirname $0`

yum install -y wget

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum repolist all | grep mysql
yum install -y mysql57-community-server

# 设置为开机启动(2、3、4都是on代表开机自动启动)
systemctl list-unit-files | grep mysqld
systemctl enable mysqld.service

# 启动mysql
systemctl start mysqld.service

# 设置root密码
mysql_secure_installation

# 登陆root账号
mysql -uroot -p

# 建立远程root用户
# mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你设置的密码' WITH GRANT OPTION;
# mysql> flush privileges;

cd -
